<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>notify-delay-rule-common</title>
	<%@ include file="../include/common.jsp"%>
	<%@ include file="../include/jbox.jsp"%>
	<%@ include file="../include/table.jsp"%>
	<script type="text/javascript">
	function datagrid(){
		var oTable=	$('#depmtList').dataTable();
		
		 oTable._fnAjaxUpdate();
	}
	$(function(){
		//加载grid
		var oTable=	$('#depmtList').dataTable({
			"bProcessing": false, 
			"bServerSide": true,
			"sServerMethod": 'POST',
			"sAjaxSource":'${pageContext.request.contextPath}/notify/notify-delay-rule!list.action',
			"bPaginate": false,
			"bSort": true,
			"bFilter":false,
			"bJQueryUI":false,
			 "fnServerParams":function(aoData){aoData.push({'name':'notifyRuleId','value':parent.document.getElementById("id").value});}
			,
			"aoColumns":[
				{"mDataProp":"op","":"center","bSortable": false},
				{"mDataProp":"date","bSortable": false},
				{"mDataProp":"id","bVisible":false}
			], 
			 "oLanguage": { 
				 "sZeroRecords": "没有找到记录",
					"sInfo":" ",
					"sInfoEmpty": " "
			}
		});
	});	

	function add() {
		if(parent.document.getElementById("id").value == ''){
			getTopWin(window).getMessageBox().alert("请先保存基本信息","提示");
		}else{
			var url ="iframe:notify/notify-delay-rule!add.action?notifyRuleId="+parent.document.getElementById("id").value;
			var opt = { title: "新增通知延迟",width:480,height:230,buttons: {}};
			getTopWin(window).openjBox(url,opt,'add-delay-rule',window);
		}
	}
	function update(id) {
		$.ajax({
    		type : "POST",
    		url : "${pageContext.request.contextPath}/notify/notify-delay-rule!checkDeleted.action", //请求的action
    		data : {id:id}, //传的参数
    		dataType : 'json',
    		success : function(data) { //结果
    			if(data.flag == true){
    				var url ="iframe:notify/notify-delay-rule!input.action?id="+id;
    				var opt = { title: "修改通知延迟",width:480,height:230,buttons: {}};
    				getTopWin(window).openjBox(url,opt,'update-delay-rule',window);
    			}else{
    				getTopWin(window).getMessageBox().alert("此条通知延迟记录已经被删除，请返回通知规则列表或刷新","提示");
    			}
    		}
    	});
	}
	function del(id){
		var submit = function (v, h, f) {
		    if (v == 'ok') {
		    	$.ajax({
		    		type : "POST",
		    		url : "${pageContext.request.contextPath}/notify/notify-delay-rule!delete.action?id="+id, //请求的action
		    		data : '', //传的参数
		    		dataType : 'json',
		    		success : function(data) { //结果
		    			window.setTimeout(function () { $.jBox.tip('删除成功。', 'success'); }, 100);
						datagrid();
		    		}
		    	});
		    }
		    else if (v == 'cancel') {
		    }
		    return true; //close
		};
		getTopWin(window).jBox.confirm("确定要删除数据吗？", "提示", submit);
	}
	function closewin(){
		  window.history.back();
	}
	</script>
	
  </head>
  
  <body>
	<div class="toolbar" id = "toolbar">
		<a class="page_add" href="javascript:add();">新增</a>
	</div>

	<div>
		<table id="depmtList" width="100%" cellpadding="0" cellspacing="0"
			border="0" class="display">
			<thead>
				<tr>
					<th width="2%">操作</th>
					<th width="40%">时间区间</th>
				</tr>
			</thead>
		</table>
	</div>
	<div style="margin-top:5px;">
		<input type="button" value="返回列表" onclick="closewin();" class="btn-4">
		<input type="button" value="上一步" onclick="parent.toBefore(3);" class="btn-4">
	    <input type="button" value="下一步" onclick="parent.toNext(3);" class="btn-4">
	</div>
</body>
</html>
